package com.learn.designPatterns.behavioral.mediator;

/**
 * @classname:
 * @Description:
 * @author: yfpu
 * @Date: 2018-09-18 17:20
 */
public class Mediator {

    private Alarm alarm;
    private Calender calender;
    private CoffeePot coffeePot;
    private Sprinkler sprinkler;

    public Mediator(Alarm alarm, Calender calender, CoffeePot coffeePot, Sprinkler sprinkler) {
        this.alarm = alarm;
        this.calender = calender;
        this.coffeePot = coffeePot;
        this.sprinkler = sprinkler;
    }

    public void doEvent(String dataType) {
        switch (dataType) {
            case "alarm":
                doAlarmEvent();
                break;
            case "coffeepot":
                doCoffeePotEvent();
                break;
            case "calender":
                doCalenderEvent();
                break;
            default:
                doSprinklerEvent();

        }
    }

    public void doAlarmEvent() {
        alarm.doAlarm();
        coffeePot.doCoffeePot();
        calender.doCalender();
        sprinkler.doSprinkler();
    }

    public void doCoffeePotEvent() {
        //...
    }

    public void doCalenderEvent() {
        //...
    }

    public void doSprinklerEvent() {
        //...
    }
}
